<!DOCTYPE html>
<html>
<head>
    <title>维修工单 - {{ order.order_number }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        @media print {
            body {
                width: 210mm;
                padding: 10mm;
            }
            .no-print {
                display: none;
            }
        }
        
        body {
            font-family: SimSun, serif;  /* 使用宋体 */
            margin: 0;
            padding: 20px;
        }
        
        .header {
            text-align: center;
            margin-bottom: 20px;
        }
        
        .title {
            font-size: 24px;
            font-weight: bold;
            margin: 10px 0;
        }
        
        .info-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 10px;
            margin-bottom: 20px;
        }
        
        .info-item {
            display: flex;
            align-items: center;
        }
        
        .info-label {
            min-width: 100px;
            font-weight: bold;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        
        th, td {
            border: 1px solid #000;
            padding: 8px;
            text-align: left;
        }
        
        .print-btn {
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-bottom: 20px;
        }

        .contact-info {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px dashed #ccc;
        }
    </style>
</head>
<body>
    <button onclick="window.print()" class="print-btn no-print">打印工单</button>
    
    <div class="header">
        <div class="title">汽车维修工单</div>
        <div>单号：{{ order.order_number }}</div>
    </div>
    
    <div class="info-grid">
        <div class="info-item">
            <span class="info-label">客户姓名：</span>
            <span>{{ order.customer.name }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">联系电话：</span>
            <span>{{ order.customer.phone }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">车型：</span>
            <span>{{ order.vehicle.model }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">车牌号：</span>
            <span>{{ order.vehicle.plate_number }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">开单时间：</span>
            <span>{{ order.created_at.strftime('%Y-%m-%d %H:%M') }}</span>
        </div>
    </div>
    
    <div class="repair-info">
        <div class="info-item">
            <span class="info-label">维修备注：</span>
            <span>{{ order.repair_notes or '无' }}</span>
        </div>
    </div>
    
    <table>
        <thead>
            <tr>
                <th>序号</th>
                <th>配件编号</th>
                <th>配件名称</th>
                <th>单位</th>
                <th>数量</th>
                <th>单价</th>
                <th>金额</th>
            </tr>
        </thead>
        <tbody>
            {% for item in order.items %}
            <tr>
                <td>{{ loop.index }}</td>
                <td>{{ item.part.part_number }}</td>
                <td>{{ item.part.name }}</td>
                <td>{{ item.part.unit }}</td>
                <td>{{ item.quantity }}</td>
                <td>{{ item.price }}</td>
                <td>{{ item.amount }}</td>
            </tr>
            {% endfor %}
            <tr>
                <td colspan="6" style="text-align: right;"><strong>合计金额：</strong></td>
                <td><strong>{{ order.total_amount }}</strong></td>
            </tr>
        </tbody>
    </table>

    <div class="contact-info">
        <div class="info-item">
            <span class="info-label">维修人员：</span>
            <span>{{ current_user.name }}</span>
        </div>
        <div class="info-item">
            <span class="info-label">联系电话：</span>
            <span>{{ current_user.mobile or '未设置' }}</span>
        </div>
    </div>
</body>
</html> 